﻿using  System.Collections.Generic;
using UnityEditor;
using UnityEngine ;
using System.IO ;

public class PackageTools
{
    //平台
    private static BuildTarget mPlatformTarget = BuildTarget.StandaloneWindows;

    //指定目录打包资源
    [MenuItem("AssetBundle/Build Target")]
    static void BuildTargetPathAssetBundle()
    {
        AssetBundlePackager.PackAllTargets(mPlatformTarget);

        UpdateFileCollector.Collect();

        AssetDatabase.Refresh();
    }

    static void GetNames()
    {
        var names = AssetDatabase.GetAllAssetBundleNames();
        foreach (var name in names)
        {
            Debug.Log("AssetBundle: " + name);
        }
    }

	[MenuItem("AssetBundle/Search Dependencies")]
    static void Search()
	{
	    GameObject[] objs = Selection.gameObjects;
        List<string> objPath = new List<string>();
	    for (int i = 0; i < objs.Length; i++)
	    {
	        string path = AssetDatabase.GetAssetPath(objs[i]);
            objPath.Add(path);
	    }

        string[] paths = AssetDatabase.GetDependencies(objPath.ToArray());
        foreach (string path in paths)
        {
            Debug.Log(path);
        }

    }
}
